package dieci.managers.rawmaterial;

import dieci.database.rawmaterial.RawMaterialHibernateDAO;
import dieci.system.RawMaterial;
import java.util.List;

/**
 *
 * @author DuckSys
 */
public class RawMaterialManager
{

    public RawMaterialManager()
    {
        this.rawMaterialDAO = new RawMaterialHibernateDAO();
    }

    public void saveRawMaterial(RawMaterial rawMaterial)
    {
        //call dao to save the rawMaterial in db
        rawMaterialDAO.saveOrUpdate(rawMaterial);
    }

    public void deleteRawMaterial(RawMaterial rawMaterial)
    {
        rawMaterialDAO.delete(rawMaterial);
    }

    public List<RawMaterial> find(String name)
    {
        if(name!=null && !name.isEmpty()){
            return rawMaterialDAO.findByMaterialName(name);
        }
        return rawMaterialDAO.list();
    }

    public RawMaterial findById(int id)
    {
        return rawMaterialDAO.findById(id);
    }
    
    public List<RawMaterial> list()
    {
        return rawMaterialDAO.list();
    }
        
    
    private RawMaterialHibernateDAO rawMaterialDAO;
}
